package control;

import jess.*;

public class WriteVent implements Userfunction {

	public String getName() {
		return "set-vent-state"; 
	}
	
	public Value call(ValueVector vv, Context c) throws JessException {
		int vent = vv.get(1).intValue(c);
		Simulator sim = InitSimulator.getSimulator(c);
		double state = vv.get(2).floatValue(c);
		try {
			sim.setVentState(vent, state);
		} catch (IllegalArgumentException iae) {
			throw new JessException("set-vent-state", "Invalid state", String.valueOf(state));
		}
		return Funcall.TRUE;
	}

}
